package org.dialMsg.ResultBean;

import lombok.Getter;
import org.dialMsg.Topic.RocketmqConstant;

/**
 * @author DPF
 */
@Getter
public class ResponseBean<T> {
// Getter 和 Setter 方法
    //   private String code = ResponseCode.MyCode()
//            .get(ResponseCode.codeEnum.SUCCESS);
    private int code;
    private String message; // 消息
    private T data; // 数据

    // 构造方法
    public ResponseBean() {
    }

    public ResponseBean(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // 成功时的静态方法
    public static <T> ResponseBean<T> success(T data) {
        return new ResponseBean<>(200, "Success", data);
    }

    // 失败时的静态方法
    public static <T> ResponseBean<T> error(int code, String message) {
        return new ResponseBean<>(code, message, null);
    }


    public void setCode(int code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResponseBean{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
